﻿using Holla.Core.Domain.Entities;

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace Holla.Core.Persistence.Configurations
{
    public class TodoConfiguration : IEntityTypeConfiguration<Todo>
    {
        public void Configure(EntityTypeBuilder<Todo> builder)
        {
            builder.ToTable("Todos");
            builder.HasKey(t => t.Id);
            builder.Property(p => p.Name).IsRequired();
            builder.Property(p => p.DateCreated).IsRequired();
            builder.Property(p => p.LastUpdated).IsRequired();
            builder.Property(p => p.Status).IsRequired().HasConversion(new EnumToStringConverter<TodoStatus>());
        }
    }
}
